const loadingTime = 6;
const step = 1;
let timer = null;
let percent = 0;

timer = setInterval(
	() => {
		if (percent >= 95) {
			clearInterval(timer);
			self.postMessage({ name: 'close' });
			return;
		}
		percent += step;
		self.postMessage({ name: 'percent', value: percent });
	},
	(loadingTime * 1000) / (100 / step),
);

timer1 = setTimeout(() => {
	clearInterval(timer);
	clearTimeout(timer1);
	self.postMessage({ name: 'percent', value: 100 });
	self.postMessage({ name: 'forceClose' });
}, 20 * 1000);
